<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/pub/include.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>后台管理--<c:choose><c:when test="${empty kpiEntity}">添加绩效</c:when><c:otherwise>修改绩效</c:otherwise></c:choose></title>
    <link href="<%=request.getContextPath() %>/css/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.form.js"></script>

    <script language="javascript" type="text/javascript">
        window.onload=function(){
//设置年份的选择
            var myDate= new Date();
            var startYear=myDate.getFullYear()-10;//起始年份
            var endYear=myDate.getFullYear()+10;//结束年份
            var myYear =document.getElementById('pryear');
            var tyYear = myDate.getFullYear();
            <c:if test="${not empty kpiEntity}">
            tyYear = ${kpiEntity.pryear} ;
            </c:if>
            var tf = 0 ;
            var fd = 0 ;

            for (var i=startYear;i<=endYear;i++)
            {
                myYear.options.add(new Option(i,i));
                if (tyYear == i) {
                    fd = tf;
                }
                tf ++;
            }
//            myYear.options[myYear.options.length-11].selected=1;
            myYear.options[fd].selected=1;

            var myjidu=document.getElementById('prjidu');
            var tyjidu = '1';
            <c:if test="${not empty kpiEntity}">
            tyjidu = ${kpiEntity.prjidu} ;
            </c:if>
            var tff = 0 ;
            var fdd = 0 ;
            for (var j=1;j <= 4;j++)
            {
                myjidu.options.add(new Option(j,j));
                if (tyjidu == j) {
                    fdd = tff;
                }
                tff++;
            }
            myjidu.options[fdd].selected=1;
        }
    </script>

    <script type="text/javascript">
        function firm() {
            //利用对话框返回的值 （true 或者 false）
            if (confirm("提交后将无法在更改基础信息，马上提交吗？")) {
                check();
            }
        }
        function check(){
            var url = getRootPath()+"/clazz/addkpi?m=doadd";
            var   userid = $("#userid").val();
            var   pryear = $("#pryear").val();
            var   prjidu = $("#prjidu").val();
//            var   focuscategory = $("#focuscategory").val();
            var   kipnum = $("#kipnum").val();
            var   doneponum = $("#doneponum").val();
            var   billnum = $("#billnum").val();

            var   id = $("#id").val();
            if(userid =="0"){
                alert("用户不能为空");
                return false;
            }
            if(kipnum==""){
                alert("kpi指标不能为空");
                return false;
            }
            if(pryear=="0"){
                alert("年份不能为空");
                return false;
            }
            if(prjidu=="0"){
                alert("季度不能为空");
                return false;
            }
            <c:if test="${not empty kpiEntity}">
            url = getRootPath()+"/clazz/addkpi?m=doedit";
            </c:if>

            var para ={
                'id' :id,
                'userid':userid,
                'pryear':pryear,
                'prjidu':prjidu,
//                'focuscategory':focuscategory,
                'kipnum':kipnum,
                'doneponum' :doneponum,
                'billnum':billnum
            }
            $.ajax({
                cache:false,
                type:"POST",
                url: url,
                dataType:"json",
                data:para,
                error:function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                },
                success:function(returndata){
                    alert(returndata.data.message);
                    if(returndata.data.suc){
                        window.location.href= getRootPath()+"/clazz/kpi?m=list";
                    }else{

                    }
                }
            });
        }
    </script>
</head>
<body>
<div class="content">
    <jsp:include page="../pub/top.jsp"></jsp:include>
    <!--头部结束-->
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="left" valign="top">
                <jsp:include page="../pub/left_clazz.jsp"></jsp:include>
            </td>
            <td valign="top">
                <div class="right">
                    <form action="<c:url value="/clazz/addkpi?m=doadd"/>" method="post" style="margin:0">
                        <table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#d1d5d8">
                            <tr>
                                <td height="28" colspan="2" bgcolor="#c6dbf8" class="biaoti" style="padding:0;">
                                    <c:choose>
                                        <c:when test="${empty kpiEntity}">添加绩效</c:when>
                                        <c:otherwise>修改绩效</c:otherwise>
                                    </c:choose>
                                </td>
                            </tr>
                            <tr>
                                <td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>时间季度：</td>
                                <td height="28" bgcolor="#FFFFFF"><select id="pryear" name="pryear" style="width:80px;"></select>年 第<select id="prjidu" name="prjidu" style="width:80px;"></select>季度</td>
                            </tr>

                            <tr>
                                <td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*</span>姓名：</td>
                                <td height="28" bgcolor="#FFFFFF">
                                    <select id="userid" name="userid" style="width:200px;">
                                        <option value="0">请选择姓名</option>
                                            <c:forEach items="${userList}" var="user">
                                                <option value="${user.id}" ${user.id==kpiEntity.user.id?'selected=selected':''}><c:out value="${user.username}"/></option>
                                            </c:forEach>
                                        <%--<c:otherwise>--%>
                                        <%--<option value="${sessionScope.user.id}">${sessionScope.user.username}</option>--%>
                                        <%--</c:otherwise>--%>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td width="15%" height="28" align="right" bgcolor="#edf1f7"><span>*季度计划金额：</span></td>
                                <td height="28" bgcolor="#FFFFFF"><input type="text" style="width:200px;" name="kipnum" id="kipnum" value="${kpiEntity.kipnum}"/></td>
                            </tr>
                            <tr>
                                <td width="15%" height="28" align="right" bgcolor="#edf1f7">已完成金额：</td>
                                <td height="28" bgcolor="#FFFFFF"><input type="text" style="width:200px;" name="doneponum" id="doneponum"  disabled="true" value="${kpiEntity.doneponum}" /></td>
                            </tr>

                            <tr>
                                <td width="15%" height="28" align="right" bgcolor="#edf1f7">已开票金额：</td>
                                <td height="28" bgcolor="#FFFFFF"><input type="text" id="billnum" style="width:200px;" name="billnum"  disabled="true" value="${kpiEntity.billnum}"  readonly/></td>
                            </tr>

                        </table>
                        <div class="anniu">
                            <p><input type="button" value="提交" class="fabu" onclick="check()"/>
                                <c:choose>
                                    <c:when test="${empty kpiEntity}"><input type="reset" value="重置" class="fabu" /></c:when>
                                    <c:otherwise><input type="button" value="返回" class="fabu" onclick="history.back()" /></c:otherwise>
                                </c:choose>
                            </p>
                            <input type="hidden" name="id"  id="id" value="${kpiEntity.id}"/>
                        </div>
                    </form>
                </div>
                <br />
                <br />
            </td>
        </tr>
    </table>
    <jsp:include page="../pub/foot.jsp"></jsp:include>
</div>

<%--<script type="text/javascript" src="<%=request.getContextPath() %>/fckeditor/fckeditor.js"></script>--%>
<%--<script type="text/javascript">--%>
<%--var oFCKeditor = new FCKeditor('intro') ;--%>
<%--oFCKeditor.BasePath	= "${pageContext.request.contextPath}/fckeditor/";--%>
<%--oFCKeditor.Width="500";--%>
<%--oFCKeditor.Height="150";--%>
<%--oFCKeditor.Value="&nbsp;&nbsp;&nbsp;&nbsp;";--%>
<%--oFCKeditor.ToolbarSet="classnet";--%>
<%--oFCKeditor.Config["CustomConfigurationsPath"]="${pageContext.request.contextPath}/fckeditor/myconfig.js?d="+new Date().getTime();--%>
<%--oFCKeditor.ReplaceTextarea();--%>
<%--</script>--%>


</body>
</html>
